package com.wb.core08_常用类.练习;

import java.util.Scanner;

/**
* @author 黄衡熙
* @version 1.0
*/
// 2.控制台输入一个字符串,修改字符串格式,例如:字符串Hello World转换为WROLD_HELLO
public class Test2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入一个字符串:");
        String str = sc.nextLine();
        str=str.toUpperCase();
        String[] arr = str.split(" ");
        System.out.print("修改后:");
        for(int i=arr.length-1;i>=0;i--){
            if(i==0){
                System.out.print(arr[i]);
            }else {
                System.out.print(arr[i] + "_");
            }
        }
    }
}
